package cn.dota2info.cleantorrent;

import java.io.File;
import java.io.InputStreamReader;
import java.io.LineNumberReader;

public class CleanTorrent {
    public static String getManageNet(String torrentPath){
        String result = "";
        String basePath=System.getProperty("user.dir")+ File.separator;

        try {
            Process process = Runtime.getRuntime().exec("python2 "+ basePath+"clean.py "+torrentPath );

            InputStreamReader ir = new InputStreamReader(process.getInputStream(),"GBK");
            LineNumberReader input = new LineNumberReader(ir);
            result = input.readLine();
            input.close();
            ir.close();
//            process.waitFor();
        } catch (Exception e) {
            System.out.println("调用python脚本并读取结果时出错：" + e.getMessage());
        }
        File file=new File(torrentPath);
        file.delete();
        File file1=new File(basePath+"new_torrent.torrent");
        file1.delete();
        return result;

    }

}
